class UtilsTagLib {
    def splitPanel={attrs->
        if(attrs.panel && attrs.panel instanceof String){
            def title=''
            if(attrs.title){
                title='title="'+attrs.title+'"'
            }
            out << '<div class="separator"><a '+title+' href="javascript:" onclick="return splitPanel(this,\''+attrs.panel+'\')" class="up">&nbsp;</a></span></div>'
        }else{
            out <<'Incorrecta definicion para este tag "splitPanel"'
        }
    }
    def buttonConsultar={attrs->
        out << '<div align="center" class="button_consultar"><input type="hidden" value="0" name="flagPaginacion"><input type="submit" class="B_CONSULTAR" value="'+message(code:'consulta.button.consultar')+'" /></div>'
    }
    
    def paginacion={attrs->
        if(attrs.totalCount){
            if(attrs.totalCount>attrs.max){
                def html='<div class="pagination" align="center">'
                html+=paginate(total:attrs.totalCount,params:[flagPaginacion:1])
                html+=observe(classes:['step','prevLink','nextLink'],event:"click",function:"observeConsulta")
                html+='</div>'
                out<<html
            }
        }else{
            out <<'Incorrecta definicion para este tag "panelReporte"'
        }
    }
    /*
     * Muestra dos listas en las que se seleccionan de una lista a la otra
     * css: utils.css
     * js: utils.js
     **/
    def selectorMultiple={attrs->

        if(attrs.nombre && attrs.titulo){
            def html='<div class="selector_multiple_doble">'
            html+='<table align="center"><tr></tr><tr>'
            html+='<td colspan="3">'+attrs.titulo+'</td></tr>'
            html+='<tr><td><select style="width:170px; height:180px; color: #666666;font-size: 11px; name="'+attrs.nombre+'_SA" id="'+attrs.nombre+'_SA" multiple class=":required" >'
            attrs.listaA.each{
                html+='<option value="'+it.id+'">'+it+'</option>'
            }
            html+='</select></td>'
            html+='<td><div><input class="boton_divi" type="button" onClick="selectorMultipleDoble(\''+attrs.nombre+'_SA\',\''+attrs.nombre+'_SB\')" value=""/></div><div><input class="boton_divi2" type="button" onClick="selectorMultipleDoble(\''+attrs.nombre+'_SB\',\''+attrs.nombre+'_SA\')" value=""/></div></td>'
            html+='<td><select  style="width:170px; height:180px; color: #666666; font-size: 11px;" multiple name="'+attrs.nombre+'_SB" id="'+attrs.nombre+'_SB">'
            attrs.listaB.each{
                html+='<option value="'+it.id+'">'+it+'</option>'
            }
            html+='</select></td></tr></table>'
            out << html           
        }else{
            out <<'Incorrecta definicion para este tag "selectorMultiple"'
        }
    }
    def errores={attrs->
        if(attrs.errors!=null && attrs.errors.size()>0){
            def html='<div class="errors"><ul>'
            attrs.errors.each{
                html+='<li>'+it+'</li>'
            }
            html+='</ul></div>'
            out<<html
        }
    }
    def detailProductCCEHeader={attrs->
        if(attrs.title && attrs.index && attrs.function){
            def html='<table width="100%" style="border:0px;margin:0px;padding:0px;">'
            html+='<tr><td width="20%"><h3 align="left">'+attrs.title+'</h3></td>'
            html+='<td width="60%" align="center"><div id="nextprev_links"></div></td>'
            html+='<td width="20%">&nbsp;</td></tr></table>'
            html+='<script>nextAndPrevButtons('+attrs.index+',"'+attrs.function+'","nextprev_links");</script>'
            out<<html
        }else{
            out <<'Incorrecta definicion para este tag "detailProductCCEHeader"'
        }
    } 
}
